<template>
  <div>
    <h3>根组件</h3>

    <hr />

    <p>
      <button @click="flag = true">tab1</button>
      <button @click="flag = false">tab2</button>
    </p>
    <!-- 显示要切换的组件 -->
    <div>
      <Page1 v-if="flag" />
      <Page2 v-else />
    </div>
  </div>
</template>

<script>
import Page1 from './views/Page1.vue'
import Page2 from './views/Page2.vue'

export default {
  data() {
    return {
      flag: true
    }
  },
  components: {
    Page1,
    Page2
  }
}
</script>

<style lang="less" scoped>
button {
  padding: 6px 20px;
  margin: 10px 15px;
}
</style>
